import { ApiCall } from "tsrpc";
import { ReqDestroy, ResDestroy } from "../../../shared/master/bag/PtlDestroy";
import { player } from "../../../model/fight/body/player";
import { prop_base } from "../../../model/bag/prop_base";
import { template } from "../../../shared/master/MsgAction";
import manage_EquipStrengthen from "../../model/manage/manage_EquipStrengthen";

export default async function (call: ApiCall<ReqDestroy, ResDestroy>) {
    call.succ({})
    let user = call.req._player as player;
    let bagArry: (prop_base | undefined)[] = user.getBagList();
    let destroyIdx = call.req.idx;
    let item = bagArry[destroyIdx - 1];
    if(!item){
        user.sendMsg(template.default,`背包内没有ID为${destroyIdx}的道具`)
        return;
    }
    manage_EquipStrengthen.clear(user.uuid,item.data);
    item.destroy();
    user.sendMsg(template.default,`已丢弃道具`)
}